cmsdk: Add search resources plumbing for CMParts
Change-Id: I541bbbabd81eb249b7696f23d5122b6a5f4f8f50
This commit is contained in:
@@ -742,6 +742,7 @@ package cyanogenmod.platform {
|
||||
field public static final int requiresOwner = 1057030150; // 0x3f010006
|
||||
field public static final int requiresPackage = 1057030146; // 0x3f010002
|
||||
field public static final int requiresProperty = 1057030149; // 0x3f010005
|
||||
field public static final int xmlRes = 1057030151; // 0x3f010007
|
||||
}
|
||||
|
||||
public static final class R.bool {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<java-symbol type="drawable" name="ic_launcher_cyanogenmod" />
|
||||
|
||||
<java-symbol type="bool" name="config_enableAppSuggestOverlay"/>
|
||||
<java-symbol type="string" name="config_appSuggestProviderPackageName"/>
|
||||
<java-symbol type="array" name="config_appSuggestProviderPackageNames"/>
|
||||
|
||||
@@ -30,4 +30,10 @@
|
||||
<attr name="requiresProperty" format="string" />
|
||||
<attr name="requiresOwner" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<!--Settings search providers-->
|
||||
<declare-styleable name="cm:Searchable">
|
||||
<attr name="xmlRes" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
<public type="attr" name="requiresProperty" id="0x3f010005" />
|
||||
<!-- Declared at vendor/cmsdk/cm/res/../../sdk/res/res/values/attrs.xml:31 -->
|
||||
<public type="attr" name="requiresOwner" id="0x3f010006" />
|
||||
<!-- Declared at vendor/cmsdk/cm/res/../../sdk/res/res/values/attrs.xml:32 -->
|
||||
<public type="attr" name="xmlRes" id="0x3f010007" />
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -6,4 +6,6 @@
|
||||
<java-symbol type="attr" name="requiresProperty" />
|
||||
<java-symbol type="attr" name="requiresOwner" />
|
||||
|
||||
<java-symbol type="attr" name="xmlRes" />
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -36,6 +36,9 @@ public class PartInfo implements Parcelable {
|
||||
|
||||
private boolean mAvailable = true;
|
||||
|
||||
/* for search provider */
|
||||
private int mXmlRes = 0;
|
||||
|
||||
public PartInfo(String name, String title, String summary) {
|
||||
mName = name;
|
||||
mTitle = title;
|
||||
@@ -56,6 +59,7 @@ public class PartInfo implements Parcelable {
|
||||
mFragmentClass = parcel.readString();
|
||||
mIconRes = parcel.readInt();
|
||||
mAvailable = parcel.readInt() == 1;
|
||||
mXmlRes = parcel.readInt();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -90,6 +94,10 @@ public class PartInfo implements Parcelable {
|
||||
|
||||
public void setAvailable(boolean available) { mAvailable = available; }
|
||||
|
||||
public int getXmlRes() { return mXmlRes; }
|
||||
|
||||
public void setXmlRes(int xmlRes) { mXmlRes = xmlRes; }
|
||||
|
||||
public void updateFrom(PartInfo other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
@@ -102,12 +110,13 @@ public class PartInfo implements Parcelable {
|
||||
setFragmentClass(other.getFragmentClass());
|
||||
setIconRes(other.getIconRes());
|
||||
setAvailable(other.isAvailable());
|
||||
setXmlRes(other.getXmlRes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("PartInfo=[ name=%s title=%s summary=%s fragment=%s ]",
|
||||
mName, mTitle, mSummary, mFragmentClass);
|
||||
return String.format("PartInfo=[ name=%s title=%s summary=%s fragment=%s xmlRes=%x ]",
|
||||
mName, mTitle, mSummary, mFragmentClass, mXmlRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +134,7 @@ public class PartInfo implements Parcelable {
|
||||
out.writeString(mFragmentClass);
|
||||
out.writeInt(mIconRes);
|
||||
out.writeInt(mAvailable ? 1 : 0);
|
||||
|
||||
out.writeInt(mXmlRes);
|
||||
parcelInfo.complete();
|
||||
}
|
||||
|
||||
@@ -135,9 +144,7 @@ public class PartInfo implements Parcelable {
|
||||
|
||||
public Intent getIntentForActivity() {
|
||||
Intent i = new Intent(getAction());
|
||||
ComponentName cn = new ComponentName(PartsList.CMPARTS_PACKAGE,
|
||||
PartsList.CMPARTS_PACKAGE + ".PartsActivity");
|
||||
i.setComponent(cn);
|
||||
i.setComponent(PartsList.CMPARTS_ACTIVITY);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.cyanogenmod.internal.cmparts;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
@@ -32,6 +33,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.android.internal.R.styleable.Preference;
|
||||
@@ -41,6 +43,8 @@ import static com.android.internal.R.styleable.Preference_key;
|
||||
import static com.android.internal.R.styleable.Preference_summary;
|
||||
import static com.android.internal.R.styleable.Preference_title;
|
||||
|
||||
import static cyanogenmod.platform.R.styleable.cm_Searchable;
|
||||
import static cyanogenmod.platform.R.styleable.cm_Searchable_xmlRes;
|
||||
|
||||
public class PartsList {
|
||||
|
||||
@@ -50,9 +54,12 @@ public class PartsList {
|
||||
public static final String EXTRA_PART_KEY = "key";
|
||||
|
||||
public static final String CMPARTS_PACKAGE = "org.cyanogenmod.cmparts";
|
||||
public static final ComponentName CMPARTS_ACTIVITY = new ComponentName(
|
||||
CMPARTS_PACKAGE, CMPARTS_PACKAGE + ".PartsActivity");
|
||||
|
||||
public static final String PARTS_ACTION_PREFIX = CMPARTS_PACKAGE + ".parts";
|
||||
|
||||
private static final Map<String, PartInfo> sParts = new ArrayMap<String, PartInfo>();
|
||||
private static final Map<String, PartInfo> sParts = new ArrayMap<>();
|
||||
|
||||
private static final AtomicBoolean sCatalogLoaded = new AtomicBoolean(false);
|
||||
|
||||
@@ -78,6 +85,15 @@ public class PartsList {
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getPartsList(Context context) {
|
||||
synchronized (sParts) {
|
||||
if (!sCatalogLoaded.get()) {
|
||||
loadParts(context);
|
||||
}
|
||||
return sParts.keySet();
|
||||
}
|
||||
}
|
||||
|
||||
public static PartInfo getPartInfo(Context context, String key) {
|
||||
synchronized (sParts) {
|
||||
if (!sCatalogLoaded.get()) {
|
||||
@@ -172,6 +188,10 @@ public class PartsList {
|
||||
|
||||
info.setFragmentClass(sa.getString(Preference_fragment));
|
||||
info.setIconRes(sa.getResourceId(Preference_icon, 0));
|
||||
|
||||
sa = res.obtainAttributes(attrs, cm_Searchable);
|
||||
info.setXmlRes(sa.getResourceId(cm_Searchable_xmlRes, 0));
|
||||
|
||||
sa.recycle();
|
||||
|
||||
target.put(key, info);
|
||||
|
||||
Reference in New Issue
Block a user