Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27097
Browse files Browse the repository at this point in the history
  • Loading branch information
ssekhri committed Jul 9, 2019
2 parents d6b70fe + e37c691 commit ecffbdf
Show file tree
Hide file tree
Showing 113 changed files with 1,710 additions and 1,344 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 @@ -732,6 +732,10 @@ public String getAllResponseHeaders()

public void clearCookies(String url)
{
if (url == null) {
return;
}

List<HttpCookie> cookies = new ArrayList<HttpCookie>(cookieManager.getCookieStore().getCookies());
cookieManager.getCookieStore().removeAll();
String lower_url = url.toLowerCase();
Expand Down
1 change: 0 additions & 1 deletion android/modules/ui/res/layout/titanium_ui_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:layout_gravity="right"
android:contentDescription="One of the following images: checkmark, child, or disclosure"
android:focusable="false"
android:focusableInTouchMode="false"
android:maxHeight="17dp"
Expand Down
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 @@ -285,7 +285,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
}
ViewCompat.setImportantForAccessibility(listView, importance);
} else {
listView.setContentDescription(composeContentDescription());
listView.setContentDescription(getProxy().composeContentDescription());
}
}
}
Expand Down Expand Up @@ -335,9 +335,9 @@ public void onCancel(DialogInterface dlg)
// can also be used.
ListView listView = dialog.getListView();
if (listView != null) {
listView.setContentDescription(composeContentDescription());
int importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
if (proxy != null) {
listView.setContentDescription(proxy.composeContentDescription());
Object propertyValue = proxy.getProperty(TiC.PROPERTY_ACCESSIBILITY_HIDDEN);
if (propertyValue != null && TiConvert.toBoolean(propertyValue)) {
importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;
Expand Down Expand Up @@ -665,8 +666,10 @@ public void populateViews(KrollDict data, TiBaseListViewItem cellContent, TiList
DataItem dataItem = template.getDataItem(binding);
ViewItem viewItem = views.get(binding);
TiUIView view = viewItem.getView();
KrollProxy viewProxy = null;
//update extra event data for views
if (view != null) {
viewProxy = view.getProxy();
appendExtraEventData(view, itemIndex, sectionIndex, binding, itemId);
}
//if binding is contain in data given to us, process that data, otherwise
Expand All @@ -675,12 +678,18 @@ public void populateViews(KrollDict data, TiBaseListViewItem cellContent, TiList
KrollDict properties = new KrollDict((HashMap) data.get(binding));
KrollDict diffProperties = viewItem.generateDiffProperties(properties);
if (!diffProperties.isEmpty()) {
if (viewProxy != null && viewProxy.getProperties() != null) {
viewProxy.getProperties().putAll(diffProperties);
}
view.processProperties(diffProperties);
}

} else if (dataItem != null && view != null) {
KrollDict diffProperties = viewItem.generateDiffProperties(dataItem.getDefaultProperties());
if (!diffProperties.isEmpty()) {
if (viewProxy != null && viewProxy.getProperties() != null) {
viewProxy.getProperties().putAll(diffProperties);
}
view.processProperties(diffProperties);
}
} else {
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
Binary file modified android/titanium/lib/aps-analytics.jar
Binary file not shown.
55 changes: 52 additions & 3 deletions android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
*/
package org.appcelerator.kroll;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.AsyncResult;
import org.appcelerator.kroll.common.Log;
Expand All @@ -35,6 +32,7 @@
import android.os.Looper;
import android.os.Message;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Pair;

import org.json.JSONObject;
Expand Down Expand Up @@ -978,6 +976,57 @@ public boolean doFireEvent(String event, Object data)
return krollObject.fireEvent(source, event, krollData, bubbles, reportSuccess, code, message);
}

/**
* Our view proxy supports three properties to match iOS regarding
* the text that is read aloud (or otherwise communicated) by the
* assistive technology: accessibilityLabel, accessibilityHint
* and accessibilityValue.
*
* We combine these to create the single Android property contentDescription.
* (e.g., View.setContentDescription(...));
*/
public String composeContentDescription()
{
if (properties == null) {
return null;
}

final String punctuationPattern = "^.*\\p{Punct}\\s*$";
StringBuilder buffer = new StringBuilder();
String label = TiConvert.toString(properties.get(TiC.PROPERTY_ACCESSIBILITY_LABEL));
String hint = TiConvert.toString(properties.get(TiC.PROPERTY_ACCESSIBILITY_HINT));
String value = TiConvert.toString(properties.get(TiC.PROPERTY_ACCESSIBILITY_VALUE));

if (!TextUtils.isEmpty(label)) {
buffer.append(label);
if (!label.matches(punctuationPattern)) {
buffer.append(".");
}
}

if (!TextUtils.isEmpty(value)) {
if (buffer.length() > 0) {
buffer.append(" ");
}
buffer.append(value);
if (!value.matches(punctuationPattern)) {
buffer.append(".");
}
}

if (!TextUtils.isEmpty(hint)) {
if (buffer.length() > 0) {
buffer.append(" ");
}
buffer.append(hint);
if (!hint.matches(punctuationPattern)) {
buffer.append(".");
}
}

return buffer.toString();
}

public void firePropertyChanged(String name, Object oldValue, Object newValue)
{
if (modelListener != null) {
Expand Down

0 comments on commit ecffbdf

Please sign in to comment.