use of com.android.launcher3.widget.WidgetSections in project android_packages_apps_404Launcher by P-404.
the class WidgetSections method parseWidgetSectionsXml.
private static synchronized void parseWidgetSectionsXml(Context context) {
SparseArray<WidgetSection> widgetSections = new SparseArray();
Map<ComponentName, IntSet> widgetsToCategories = new ArrayMap<>();
try (XmlResourceParser parser = context.getResources().getXml(R.xml.widget_sections)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_SECTION_NAME.equals(parser.getName())) {
AttributeSet sectionAttributes = Xml.asAttributeSet(parser);
WidgetSection section = new WidgetSection(context, sectionAttributes);
final int sectionDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > sectionDepth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_WIDGET_NAME.equals(parser.getName())) {
TypedArray a = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.WidgetSections);
ComponentName provider = ComponentName.unflattenFromString(a.getString(R.styleable.WidgetSections_provider));
boolean alsoKeepInApp = a.getBoolean(R.styleable.WidgetSections_alsoKeepInApp, /* defValue= */
false);
final IntSet categories;
if (widgetsToCategories.containsKey(provider)) {
categories = widgetsToCategories.get(provider);
} else {
categories = new IntSet();
widgetsToCategories.put(provider, categories);
}
if (alsoKeepInApp) {
categories.add(NO_CATEGORY);
}
categories.add(section.mCategory);
}
}
widgetSections.put(section.mCategory, section);
}
}
sWidgetSections = widgetSections;
sWidgetsToCategories = widgetsToCategories;
} catch (IOException | XmlPullParserException e) {
throw new RuntimeException(e);
}
}
use of com.android.launcher3.widget.WidgetSections in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetSections method parseWidgetSectionsXml.
private static synchronized void parseWidgetSectionsXml(Context context) {
SparseArray<WidgetSection> widgetSections = new SparseArray();
Map<ComponentName, IntSet> widgetsToCategories = new ArrayMap<>();
try (XmlResourceParser parser = context.getResources().getXml(R.xml.widget_sections)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_SECTION_NAME.equals(parser.getName())) {
AttributeSet sectionAttributes = Xml.asAttributeSet(parser);
WidgetSection section = new WidgetSection(context, sectionAttributes);
final int sectionDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > sectionDepth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_WIDGET_NAME.equals(parser.getName())) {
TypedArray a = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.WidgetSections);
ComponentName provider = ComponentName.unflattenFromString(a.getString(R.styleable.WidgetSections_provider));
boolean alsoKeepInApp = a.getBoolean(R.styleable.WidgetSections_alsoKeepInApp, /* defValue= */
false);
final IntSet categories;
if (widgetsToCategories.containsKey(provider)) {
categories = widgetsToCategories.get(provider);
} else {
categories = new IntSet();
widgetsToCategories.put(provider, categories);
}
if (alsoKeepInApp) {
categories.add(NO_CATEGORY);
}
categories.add(section.mCategory);
}
}
widgetSections.put(section.mCategory, section);
}
}
sWidgetSections = widgetSections;
sWidgetsToCategories = widgetsToCategories;
} catch (IOException | XmlPullParserException e) {
throw new RuntimeException(e);
}
}
use of com.android.launcher3.widget.WidgetSections in project android_packages_apps_Launcher3 by ProtonAOSP.
the class WidgetSections method parseWidgetSectionsXml.
private static synchronized void parseWidgetSectionsXml(Context context) {
SparseArray<WidgetSection> widgetSections = new SparseArray();
Map<ComponentName, IntSet> widgetsToCategories = new ArrayMap<>();
try (XmlResourceParser parser = context.getResources().getXml(R.xml.widget_sections)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_SECTION_NAME.equals(parser.getName())) {
AttributeSet sectionAttributes = Xml.asAttributeSet(parser);
WidgetSection section = new WidgetSection(context, sectionAttributes);
final int sectionDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > sectionDepth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_WIDGET_NAME.equals(parser.getName())) {
TypedArray a = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.WidgetSections);
ComponentName provider = ComponentName.unflattenFromString(a.getString(R.styleable.WidgetSections_provider));
boolean alsoKeepInApp = a.getBoolean(R.styleable.WidgetSections_alsoKeepInApp, /* defValue= */
false);
final IntSet categories;
if (widgetsToCategories.containsKey(provider)) {
categories = widgetsToCategories.get(provider);
} else {
categories = new IntSet();
widgetsToCategories.put(provider, categories);
}
if (alsoKeepInApp) {
categories.add(NO_CATEGORY);
}
categories.add(section.mCategory);
}
}
widgetSections.put(section.mCategory, section);
}
}
sWidgetSections = widgetSections;
sWidgetsToCategories = widgetsToCategories;
} catch (IOException | XmlPullParserException e) {
throw new RuntimeException(e);
}
}
use of com.android.launcher3.widget.WidgetSections in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetSections method parseWidgetSectionsXml.
private static synchronized void parseWidgetSectionsXml(Context context) {
SparseArray<WidgetSection> widgetSections = new SparseArray();
Map<ComponentName, IntSet> widgetsToCategories = new ArrayMap<>();
try (XmlResourceParser parser = context.getResources().getXml(R.xml.widget_sections)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_SECTION_NAME.equals(parser.getName())) {
AttributeSet sectionAttributes = Xml.asAttributeSet(parser);
WidgetSection section = new WidgetSection(context, sectionAttributes);
final int sectionDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > sectionDepth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && TAG_WIDGET_NAME.equals(parser.getName())) {
TypedArray a = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.WidgetSections);
ComponentName provider = ComponentName.unflattenFromString(a.getString(R.styleable.WidgetSections_provider));
boolean alsoKeepInApp = a.getBoolean(R.styleable.WidgetSections_alsoKeepInApp, /* defValue= */
false);
final IntSet categories;
if (widgetsToCategories.containsKey(provider)) {
categories = widgetsToCategories.get(provider);
} else {
categories = new IntSet();
widgetsToCategories.put(provider, categories);
}
if (alsoKeepInApp) {
categories.add(NO_CATEGORY);
}
categories.add(section.mCategory);
}
}
widgetSections.put(section.mCategory, section);
}
}
sWidgetSections = widgetSections;
sWidgetsToCategories = widgetsToCategories;
} catch (IOException | XmlPullParserException e) {
throw new RuntimeException(e);
}
}
Aggregations