Merge "Move xmlParserUtils to core"
This commit is contained in:
committed by
Android (Google) Code Review
commit
28188cdd21
@@ -12,10 +12,9 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.android.settings.search;
|
||||
package com.android.settings.core;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -27,7 +26,7 @@ import com.android.settings.R;
|
||||
/**
|
||||
* Utility class to parse elements of XML preferences
|
||||
*/
|
||||
public class XmlParserUtils {
|
||||
public class PreferenceXmlParserUtils {
|
||||
|
||||
private static final String ENTRIES_SEPARATOR = "|";
|
||||
|
@@ -29,6 +29,7 @@ import android.util.Xml;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
@@ -119,7 +120,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
try {
|
||||
while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
||||
final String key = XmlParserUtils.getDataKey(context, attrs);
|
||||
final String key = PreferenceXmlParserUtils.getDataKey(context, attrs);
|
||||
if (!TextUtils.isEmpty(key)) {
|
||||
nonIndexableKeys.add(key);
|
||||
}
|
||||
|
@@ -29,11 +29,10 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settings.search.ResultPayload;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.search.XmlParserUtils;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -161,8 +160,8 @@ public class IndexDataConverter {
|
||||
final int outerDepth = parser.getDepth();
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
final String screenTitle = XmlParserUtils.getDataTitle(context, attrs);
|
||||
String key = XmlParserUtils.getDataKey(context, attrs);
|
||||
final String screenTitle = PreferenceXmlParserUtils.getDataTitle(context, attrs);
|
||||
String key = PreferenceXmlParserUtils.getDataKey(context, attrs);
|
||||
|
||||
String title;
|
||||
String headerTitle;
|
||||
@@ -186,9 +185,9 @@ public class IndexDataConverter {
|
||||
.getPayloadKeyMap(fragmentName, context);
|
||||
}
|
||||
|
||||
headerTitle = XmlParserUtils.getDataTitle(context, attrs);
|
||||
headerSummary = XmlParserUtils.getDataSummary(context, attrs);
|
||||
headerKeywords = XmlParserUtils.getDataKeywords(context, attrs);
|
||||
headerTitle = PreferenceXmlParserUtils.getDataTitle(context, attrs);
|
||||
headerSummary = PreferenceXmlParserUtils.getDataSummary(context, attrs);
|
||||
headerKeywords = PreferenceXmlParserUtils.getDataKeywords(context, attrs);
|
||||
enabled = !nonIndexableKeys.contains(key);
|
||||
|
||||
// TODO: Set payload type for header results
|
||||
@@ -217,11 +216,11 @@ public class IndexDataConverter {
|
||||
|
||||
nodeName = parser.getName();
|
||||
|
||||
title = XmlParserUtils.getDataTitle(context, attrs);
|
||||
key = XmlParserUtils.getDataKey(context, attrs);
|
||||
title = PreferenceXmlParserUtils.getDataTitle(context, attrs);
|
||||
key = PreferenceXmlParserUtils.getDataKey(context, attrs);
|
||||
enabled = !nonIndexableKeys.contains(key);
|
||||
keywords = XmlParserUtils.getDataKeywords(context, attrs);
|
||||
iconResId = XmlParserUtils.getDataIcon(context, attrs);
|
||||
keywords = PreferenceXmlParserUtils.getDataKeywords(context, attrs);
|
||||
iconResId = PreferenceXmlParserUtils.getDataIcon(context, attrs);
|
||||
|
||||
if (isHeaderUnique && TextUtils.equals(headerTitle, title)) {
|
||||
isHeaderUnique = false;
|
||||
@@ -241,17 +240,17 @@ public class IndexDataConverter {
|
||||
.setUserId(-1 /* default user id */);
|
||||
|
||||
if (!nodeName.equals(NODE_NAME_CHECK_BOX_PREFERENCE)) {
|
||||
summary = XmlParserUtils.getDataSummary(context, attrs);
|
||||
summary = PreferenceXmlParserUtils.getDataSummary(context, attrs);
|
||||
|
||||
String entries = null;
|
||||
|
||||
if (nodeName.endsWith(NODE_NAME_LIST_PREFERENCE)) {
|
||||
entries = XmlParserUtils.getDataEntries(context, attrs);
|
||||
entries = PreferenceXmlParserUtils.getDataEntries(context, attrs);
|
||||
}
|
||||
|
||||
// TODO (b/62254931) index primitives instead of payload
|
||||
payload = controllerUriMap.get(key);
|
||||
childFragment = XmlParserUtils.getDataChildFragment(context, attrs);
|
||||
childFragment = PreferenceXmlParserUtils.getDataChildFragment(context, attrs);
|
||||
|
||||
builder.setSummaryOn(summary)
|
||||
.setEntries(entries)
|
||||
@@ -263,11 +262,11 @@ public class IndexDataConverter {
|
||||
// TODO (b/33577327) We removed summary off here. We should check if we can
|
||||
// merge this 'else' section with the one above. Put a break point to
|
||||
// investigate.
|
||||
String summaryOn = XmlParserUtils.getDataSummaryOn(context, attrs);
|
||||
String summaryOff = XmlParserUtils.getDataSummaryOff(context, attrs);
|
||||
String summaryOn = PreferenceXmlParserUtils.getDataSummaryOn(context, attrs);
|
||||
String summaryOff = PreferenceXmlParserUtils.getDataSummaryOff(context, attrs);
|
||||
|
||||
if (TextUtils.isEmpty(summaryOn) && TextUtils.isEmpty(summaryOff)) {
|
||||
summaryOn = XmlParserUtils.getDataSummary(context, attrs);
|
||||
summaryOn = PreferenceXmlParserUtils.getDataSummary(context, attrs);
|
||||
}
|
||||
|
||||
builder.setSummaryOn(summaryOn);
|
||||
|
@@ -30,7 +30,7 @@ import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable.SearchIndexProvider;
|
||||
import com.android.settings.search.XmlParserUtils;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -151,7 +151,7 @@ class SliceDataConverter {
|
||||
|
||||
final int outerDepth = parser.getDepth();
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
final String screenTitle = XmlParserUtils.getDataTitle(mContext, attrs);
|
||||
final String screenTitle = PreferenceXmlParserUtils.getDataTitle(mContext, attrs);
|
||||
|
||||
// TODO (b/67996923) Investigate if we need headers for Slices, since they never
|
||||
// correspond to an actual setting.
|
||||
@@ -168,15 +168,15 @@ class SliceDataConverter {
|
||||
// TODO (b/67996923) This will not work if preferences have nested intents:
|
||||
// <pref ....>
|
||||
// <intent action="blab"/> </pref>
|
||||
controllerClassName = XmlParserUtils.getController(mContext, attrs);
|
||||
controllerClassName = PreferenceXmlParserUtils.getController(mContext, attrs);
|
||||
if (TextUtils.isEmpty(controllerClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
title = XmlParserUtils.getDataTitle(mContext, attrs);
|
||||
key = XmlParserUtils.getDataKey(mContext, attrs);
|
||||
iconResId = XmlParserUtils.getDataIcon(mContext, attrs);
|
||||
summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
||||
title = PreferenceXmlParserUtils.getDataTitle(mContext, attrs);
|
||||
key = PreferenceXmlParserUtils.getDataKey(mContext, attrs);
|
||||
iconResId = PreferenceXmlParserUtils.getDataIcon(mContext, attrs);
|
||||
summary = PreferenceXmlParserUtils.getDataSummary(mContext, attrs);
|
||||
|
||||
xmlSlice = new SliceData.Builder()
|
||||
.setKey(key)
|
||||
|
Reference in New Issue
Block a user