-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(android)(8_1_X): set ListItem properties into proxy properties #10979
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract temp var to assign viewProxy.getProperties() value to? |
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
viewProxy.getProperties().putAll(diffProperties); | ||
} | ||
view.processProperties(diffProperties); | ||
} | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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*$"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extract to a constant so it's compiled once? |
||
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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These three small blocks are identical, extract to a method? Only wrinkle is the extra space prefix/suffix added if previous value was not empty...
|
||
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can getProxy() return null?