Skip to content

Commit

Permalink
Merge branch '8_1_X' into TIMOB-26770-8_1_X
Browse files Browse the repository at this point in the history
  • Loading branch information
keerthi1032 committed Jul 1, 2019
2 parents 04cf434 + 7305765 commit 71e7d80
Show file tree
Hide file tree
Showing 20 changed files with 605 additions and 592 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,14 @@ public String getApiName()
{
return "Ti.Database.ResultSet";
}

@Override
public void release()
{

// Close ResultSet on cleanup.
this.close();

super.release();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiUIHelper;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
Expand Down Expand Up @@ -97,16 +98,14 @@ public void handleCreationDict(KrollDict dict)
shortcut = shortcutBuilder.build();

// obtain and update any pre-existing shortcuts
for (ShortcutInfo shortcut : this.shortcuts) {
for (ShortcutInfo shortcut : new ArrayList<>(this.shortcuts)) {
if (shortcut.getId().equals(this.shortcut.getId())) {
this.shortcuts.remove(shortcut);
break;
}
}
this.shortcutManager.setDynamicShortcuts(shortcuts);
for (ShortcutInfo shortcut : this.shortcutManager.getDynamicShortcuts()) {
if (shortcut.getId().equals(this.shortcut.getId())) {
this.shortcutManager.removeDynamicShortcuts(Arrays.asList(shortcut.getId()));
this.shortcuts.remove(shortcut);
if (shortcut.isEnabled()) {
this.show();
}
Expand All @@ -118,6 +117,7 @@ public void handleCreationDict(KrollDict dict)
super.handleCreationDict(dict);
}

@SuppressLint("NewApi")
@Kroll.method
public void show()
{
Expand All @@ -129,6 +129,7 @@ public void show()
}
}

@SuppressLint("NewApi")
@Kroll.method
public void hide()
{
Expand Down Expand Up @@ -160,6 +161,7 @@ public void pin()
}

// clang-format off
@SuppressLint("NewApi")
@Kroll.method
@Kroll.getProperty
public String getId()
Expand All @@ -183,6 +185,7 @@ public boolean getVisible()
return false;
}

@SuppressLint("NewApi")
@Override
public void release()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiCompositeLayout;

Expand Down Expand Up @@ -220,9 +221,10 @@ public void removeTabItemFromController(int position)
public void selectTabItemInController(int position)
{
// Fire the UNSELECTED event from the currently selected tab.
if (currentlySelectedIndex != -1) {
if (getProxy() != null) {
tabs.get(currentlySelectedIndex).getProxy().fireEvent(TiC.EVENT_UNSELECTED, null, false);
if ((currentlySelectedIndex >= 0) && (currentlySelectedIndex < this.tabs.size()) && (getProxy() != null)) {
TiViewProxy tabProxy = this.tabs.get(currentlySelectedIndex).getProxy();
if (tabProxy != null) {
tabProxy.fireEvent(TiC.EVENT_UNSELECTED, null, false);
}
}
currentlySelectedIndex = position;
Expand Down Expand Up @@ -258,8 +260,17 @@ public void updateTabBackgroundDrawable(int index)
@Override
public void updateTabTitle(int index)
{
this.mBottomNavigationView.getMenu().getItem(index).setTitle(
tabs.get(index).getProxy().getProperty(TiC.PROPERTY_TITLE).toString());
if ((index < 0) || (index >= this.tabs.size())) {
return;
}

TiViewProxy tabProxy = this.tabs.get(index).getProxy();
if (tabProxy == null) {
return;
}

String title = TiConvert.toString(tabProxy.getProperty(TiC.PROPERTY_TITLE));
this.mBottomNavigationView.getMenu().getItem(index).setTitle(title);
}

@Override
Expand All @@ -281,7 +292,16 @@ public void updateTabTitleColor(int index)
@Override
public void updateTabIcon(int index)
{
Drawable drawable = TiUIHelper.getResourceDrawable(tabs.get(index).getProxy().getProperty(TiC.PROPERTY_ICON));
if ((index < 0) || (index >= this.tabs.size())) {
return;
}

TiViewProxy tabProxy = this.tabs.get(index).getProxy();
if (tabProxy == null) {
return;
}

Drawable drawable = TiUIHelper.getResourceDrawable(tabProxy.getProperty(TiC.PROPERTY_ICON));
this.mBottomNavigationView.getMenu().getItem(index).setIcon(drawable);
}

Expand All @@ -306,11 +326,14 @@ public boolean onMenuItemClick(MenuItem item)
{
// The controller has changed its selected item.
int index = this.mMenuItemsArray.indexOf(item);
if (index != currentlySelectedIndex) {
if (getProxy() != null) {
tabs.get(currentlySelectedIndex).getProxy().fireEvent(TiC.EVENT_UNSELECTED, null, false);
currentlySelectedIndex = index;
if ((index != currentlySelectedIndex) && (getProxy() != null)) {
if ((currentlySelectedIndex >= 0) && (currentlySelectedIndex < this.tabs.size())) {
TiViewProxy tabProxy = this.tabs.get(currentlySelectedIndex).getProxy();
if (tabProxy != null) {
tabProxy.fireEvent(TiC.EVENT_UNSELECTED, null, false);
}
}
currentlySelectedIndex = index;
}
// Make the ViewPager to select the proper page too.
selectTab(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiCompositeLayout;

Expand Down Expand Up @@ -219,7 +220,17 @@ public void updateTabBackgroundDrawable(int index)
@Override
public void updateTabTitle(int index)
{
this.mTabLayout.getTabAt(index).setText(tabs.get(index).getProxy().getProperty(TiC.PROPERTY_TITLE).toString());
if ((index < 0) || (index >= this.tabs.size())) {
return;
}

TiViewProxy tabProxy = this.tabs.get(index).getProxy();
if (tabProxy == null) {
return;
}

String title = TiConvert.toString(tabProxy.getProperty(TiC.PROPERTY_TITLE));
this.mTabLayout.getTabAt(index).setText(title);
}

@Override
Expand Down Expand Up @@ -298,16 +309,15 @@ public void onTabSelected(TabLayout.Tab tab)
@Override
public void onTabUnselected(TabLayout.Tab tab)
{
int position = tab.getPosition();
// skip invalid position tabs
if (position < 0) {
return;
}

if (position >= tabs.size()) { // skip if past end of list
return;
if (tab != null) {
int index = tab.getPosition();
if ((index >= 0) && (index < this.tabs.size())) {
TiViewProxy tabProxy = this.tabs.get(index).getProxy();
if (tabProxy != null) {
tabProxy.fireEvent(TiC.EVENT_UNSELECTED, null, false);
}
}
}
tabs.get(position).getProxy().fireEvent(TiC.EVENT_UNSELECTED, null, false);
}

@Override
Expand Down
50 changes: 48 additions & 2 deletions apidoc/Titanium/Database/DB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ methods:
var rows = db.execute('SELECT rowid,name,phone_number,city FROM people');
db.close();
while (rows.isValidRow())
{
while (rows.isValidRow()) {
Ti.API.info('Person ---> ROWID: ' + rows.fieldByName('rowid') + ', name:' + rows.field(1) + ', phone_number: ' + rows.fieldByName('phone_number') + ', city: ' + rows.field(3));
rows.next();
}
Expand All @@ -61,6 +60,53 @@ methods:
Note that the above `SELECT` query contains the [rowid](http://www.sqlite.org/lang_createtable.html#rowid)
column, which is a SQLite-specific column that stores the unique identifier for each row.
- name: executeAsync
summary: |
Asynchronously executes an SQL statement against the database and fires a callback with a `ResultSet`.
platforms: [android]
parameters:
- name: query
summary: SQL query to execute. May include placeholders for parameter substitution.
type: String

- name: vararg
summary: |
Either a variable ordered list of zero or more values, or an array of values,
to be substituted with the respective `?` placeholder of the query.
type: [String, Array<String>, Object, Array<Object>]
optional: true

- name: callback
summary: Callback when query execution has completed.
type: Callback<Titanium.Database.ResultSet>
since: { android: "8.1.0" }

- name: executeAll
summary: |
Synchronously executes an array of SQL statements against the database and fires a callback with an array of `ResultSet`.
returns:
type: Array<Titanium.Database.ResultSet>
platforms: [android]
parameters:
- name: queries
summary: Array of SQL queries to execute.
type: Array<String>
since: { android: "8.1.0" }

- name: executeAllAsync
summary: |
Asynchronously executes an array of SQL statements against the database and fires a callback with an array of `ResultSet`.
platforms: [android]
parameters:
- name: queries
summary: Array of SQL queries to execute.
type: Array<String>

- name: callback
summary: Callback when query execution has completed.
type: Callback<Array<Titanium.Database.ResultSet>>
since: { android: "8.1.0" }

- name: remove
summary: |
Removes the database files for this instance from disk. WARNING: this is a destructive
Expand Down
25 changes: 25 additions & 0 deletions iphone/Classes/TiUtils+Addons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2019-present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import <TitaniumKit/TiUtils.h>

NS_ASSUME_NONNULL_BEGIN

@interface TiUtils (Addons)

/**
Returns a unique identifier for this app.
This will change upon a fresh install.
@return UUID for this app.
*/
+ (NSString *)appIdentifier;

@end

NS_ASSUME_NONNULL_END
27 changes: 27 additions & 0 deletions iphone/Classes/TiUtils+Addons.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2019-present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import "TiUtils+Addons.h"

static NSString *kAppUUIDString = @"com.appcelerator.uuid";

@implementation TiUtils (Addons)

+ (NSString *)appIdentifier
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *uid = [defaults stringForKey:kAppUUIDString];
if (uid == nil) {
uid = [TiUtils createUUID];
[defaults setObject:uid forKey:kAppUUIDString];
[defaults synchronize];
}

return uid;
}

@end
2 changes: 0 additions & 2 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,6 @@ typedef enum {
*/
+ (NSString *)convertToHex:(unsigned char *)input length:(size_t)length;

+ (NSString *)appIdentifier;

+ (NSString *)getResponseHeader:(NSString *)header fromHeaders:(NSDictionary *)responseHeaders;

+ (UIImage *)loadBackgroundImage:(id)image forProxy:(TiProxy *)proxy;
Expand Down
14 changes: 0 additions & 14 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
static NSDictionary *encodingMap = nil;
static NSDictionary *typeMap = nil;
static NSDictionary *sizeMap = nil;
static NSString *kAppUUIDString = @"com.appcelerator.uuid"; // don't obfuscate

@implementation TiUtils

Expand Down Expand Up @@ -1904,19 +1903,6 @@ + (NSString *)md5:(NSData *)data
return [self convertToHex:(unsigned char *)&result length:CC_MD5_DIGEST_LENGTH];
}

+ (NSString *)appIdentifier
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *uid = [defaults stringForKey:kAppUUIDString];
if (uid == nil) {
uid = [TiUtils createUUID];
[defaults setObject:uid forKey:kAppUUIDString];
[defaults synchronize];
}

return uid;
}

// In pre-iOS 5, it looks like response headers were case-mangled.
// (i.e. WWW-Authenticate became Www-Authenticate). So we have to take this
// mangling into mind; headers such as FooBar-XYZ may also have been mangled
Expand Down
10 changes: 8 additions & 2 deletions iphone/iphone/Titanium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
3AB9137C1BB60F070063A4AD /* TiPreviewingDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AB9137B1BB60F070063A4AD /* TiPreviewingDelegate.m */; };
3AB913801BB61FDA0063A4AD /* TiUIiOSPreviewActionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AB9137F1BB61FDA0063A4AD /* TiUIiOSPreviewActionProxy.m */; };
3ABA85AB1D7204B100BCD3F1 /* TiAppiOSSearchQueryProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ABA85AA1D7204B100BCD3F1 /* TiAppiOSSearchQueryProxy.m */; };
4A4D3A9022C0CE6A003D2DB7 /* TiUtils+Addons.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4D3A8F22C0CE6A003D2DB7 /* TiUtils+Addons.m */; };
502A68DA16EEAA7500661EF6 /* TiUIListItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 502A68D116EEAA7500661EF6 /* TiUIListItem.m */; };
502A68DD16EEAA7500661EF6 /* TiUIListItemProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 502A68D316EEAA7500661EF6 /* TiUIListItemProxy.m */; };
502A68E016EEAA7500661EF6 /* TiUIListSectionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 502A68D516EEAA7500661EF6 /* TiUIListSectionProxy.m */; };
Expand Down Expand Up @@ -625,6 +626,8 @@
3AB9137F1BB61FDA0063A4AD /* TiUIiOSPreviewActionProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUIiOSPreviewActionProxy.m; sourceTree = "<group>"; };
3ABA85A91D7204B100BCD3F1 /* TiAppiOSSearchQueryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiAppiOSSearchQueryProxy.h; sourceTree = "<group>"; };
3ABA85AA1D7204B100BCD3F1 /* TiAppiOSSearchQueryProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiAppiOSSearchQueryProxy.m; sourceTree = "<group>"; };
4A4D3A8E22C0CE6A003D2DB7 /* TiUtils+Addons.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TiUtils+Addons.h"; sourceTree = "<group>"; };
4A4D3A8F22C0CE6A003D2DB7 /* TiUtils+Addons.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "TiUtils+Addons.m"; sourceTree = "<group>"; };
50115A9315D5DE0500122055 /* ThirdpartyNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThirdpartyNS.h; path = ../Classes/ThirdpartyNS.h; sourceTree = SOURCE_ROOT; };
502A68D016EEAA7500661EF6 /* TiUIListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiUIListItem.h; sourceTree = "<group>"; };
502A68D116EEAA7500661EF6 /* TiUIListItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUIListItem.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1983,10 +1986,12 @@
DBF30940210F36E10001F770 /* TitaniumKit Extensions */ = {
isa = PBXGroup;
children = (
DBF30942210F37080001F770 /* TiWindowProxy+Addons.h */,
DBF30943210F37080001F770 /* TiWindowProxy+Addons.m */,
DBF30945210F3B420001F770 /* TiApp+Addons.h */,
DBF30946210F3B420001F770 /* TiApp+Addons.m */,
4A4D3A8E22C0CE6A003D2DB7 /* TiUtils+Addons.h */,
4A4D3A8F22C0CE6A003D2DB7 /* TiUtils+Addons.m */,
DBF30942210F37080001F770 /* TiWindowProxy+Addons.h */,
DBF30943210F37080001F770 /* TiWindowProxy+Addons.m */,
);
name = "TitaniumKit Extensions";
sourceTree = "<group>";
Expand Down Expand Up @@ -2194,6 +2199,7 @@
1592CC3A1C496EFB00C3DB83 /* TiUIiOSRowAnimationStyleProxy.m in Sources */,
24CA8BAA111161FE0084E2DE /* TiUIButton.m in Sources */,
24CA8BAC111161FE0084E2DE /* TiUIAlertDialogProxy.m in Sources */,
4A4D3A9022C0CE6A003D2DB7 /* TiUtils+Addons.m in Sources */,
24CA8BAE111161FE0084E2DE /* TiUIActivityIndicatorProxy.m in Sources */,
24CA8BAF111161FE0084E2DE /* TiUIActivityIndicator.m in Sources */,
24CA8BBC111161FE0084E2DE /* TiMediaVideoPlayerProxy.m in Sources */,
Expand Down

0 comments on commit 71e7d80

Please sign in to comment.