List of usage examples for android.util AttributeSet getAttributeResourceValue
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue);
From source file:com.anysoftkeyboard.keyboardextensions.KeyboardExtensionFactory.java
@Override protected KeyboardExtension createConcreteAddOn(Context askContext, Context context, String prefId, int nameResId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) { int keyboardResId = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID);//from w w w.j a v a 2 s.c o m if (keyboardResId == AddOn.INVALID_RES_ID) keyboardResId = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); @KeyboardExtension.KeyboardExtensionType int extensionType = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE, AddOn.INVALID_RES_ID); if (extensionType != AddOn.INVALID_RES_ID) { extensionType = KeyboardExtension.ensureValidType(context.getResources().getInteger(extensionType)); } else { extensionType = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE, AddOn.INVALID_RES_ID); } Logger.d(mTag, "Parsing Extension Keyboard! prefId %s, keyboardResId %d, type %d", prefId, keyboardResId, extensionType); if (extensionType == AddOn.INVALID_RES_ID) { throw new RuntimeException(String.format(Locale.US, "Missing details for creating Extension Keyboard! prefId %s\nkeyboardResId: %d, type: %d", prefId, keyboardResId, extensionType)); } else { return new KeyboardExtension(askContext, context, prefId, nameResId, keyboardResId, extensionType, description, isHidden, sortIndex); } }
From source file:com.anysoftkeyboard.quicktextkeys.QuickTextKeyFactory.java
@Nullable private CharSequence getTextFromResourceOrText(Context context, AttributeSet attrs, String attributeName) { final int keyLabelResId = attrs.getAttributeResourceValue(null, attributeName, AddOn.INVALID_RES_ID); if (keyLabelResId != AddOn.INVALID_RES_ID) { return context.getResources().getText(keyLabelResId); } else {/* w ww . ja v a 2 s .co m*/ return null; } }
From source file:com.yek.keyboard.quicktextkeys.QuickTextKeyFactory.java
@Override protected QuickTextKey createConcreteAddOn(Context askContext, Context context, String prefId, int nameResId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) { final int popupKeyboardResId = attrs.getAttributeResourceValue(null, XML_POPUP_KEYBOARD_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID);/*from w ww. jav a2 s . co m*/ final int popupListTextResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_TEXT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int popupListOutputResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_OUTPUT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int popupListIconsResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_ICONS_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int iconResId = attrs.getAttributeResourceValue(null, XML_ICON_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); // Maybe should make a default // icon final int keyLabelResId = attrs.getAttributeResourceValue(null, XML_KEY_LABEL_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int keyOutputTextResId = attrs.getAttributeResourceValue(null, XML_KEY_OUTPUT_TEXT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int keyIconPreviewResId = attrs.getAttributeResourceValue(null, XML_ICON_PREVIEW_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); if (((popupKeyboardResId == AddOn.INVALID_RES_ID) && ((popupListTextResId == AddOn.INVALID_RES_ID) || (popupListOutputResId == AddOn.INVALID_RES_ID))) || ((iconResId == AddOn.INVALID_RES_ID) && (keyLabelResId == AddOn.INVALID_RES_ID)) || (keyOutputTextResId == AddOn.INVALID_RES_ID)) { String detailMessage = String.format(Locale.US, "Missing details for creating QuickTextKey! prefId %s, popupKeyboardResId: %d, popupListTextResId: %d, popupListOutputResId: %d, (iconResId: %d, keyLabelResId: %d), keyOutputTextResId: %d", prefId, popupKeyboardResId, popupListTextResId, popupListOutputResId, iconResId, keyLabelResId, keyOutputTextResId); throw new RuntimeException(detailMessage); } return new QuickTextKey(askContext, context, prefId, nameResId, popupKeyboardResId, popupListTextResId, popupListOutputResId, popupListIconsResId, iconResId, keyLabelResId, keyOutputTextResId, keyIconPreviewResId, isHidden, description, sortIndex); }
From source file:com.anysoftkeyboard.quicktextkeys.QuickTextKeyFactory.java
@Override protected QuickTextKey createConcreteAddOn(Context askContext, Context context, String prefId, int nameResId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) { final int popupKeyboardResId = attrs.getAttributeResourceValue(null, XML_POPUP_KEYBOARD_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID);//w ww. j a v a 2 s. c o m final int popupListTextResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_TEXT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int popupListOutputResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_OUTPUT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int popupListIconsResId = attrs.getAttributeResourceValue(null, XML_POPUP_LIST_ICONS_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); final int iconResId = attrs.getAttributeResourceValue(null, XML_ICON_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); // Maybe should make a default final CharSequence keyLabel = getTextFromResourceOrText(context, attrs, XML_KEY_LABEL_RES_ID_ATTRIBUTE); final CharSequence keyOutputText = getTextFromResourceOrText(context, attrs, XML_KEY_OUTPUT_TEXT_RES_ID_ATTRIBUTE); final int keyIconPreviewResId = attrs.getAttributeResourceValue(null, XML_ICON_PREVIEW_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID); if (((popupKeyboardResId == AddOn.INVALID_RES_ID) && ((popupListTextResId == AddOn.INVALID_RES_ID) || (popupListOutputResId == AddOn.INVALID_RES_ID))) || ((iconResId == AddOn.INVALID_RES_ID) && (keyLabel == null)) || (keyOutputText == null)) { String detailMessage = String.format(Locale.US, "Missing details for creating QuickTextKey! prefId %s, popupKeyboardResId: %d, popupListTextResId: %d, popupListOutputResId: %d, (iconResId: %d, keyLabel: %s), keyOutputText: %s", prefId, popupKeyboardResId, popupListTextResId, popupListOutputResId, iconResId, keyLabel, keyOutputText); throw new RuntimeException(detailMessage); } return new QuickTextKey(askContext, context, prefId, nameResId, popupKeyboardResId, popupListTextResId, popupListOutputResId, popupListIconsResId, iconResId, keyLabel, keyOutputText, keyIconPreviewResId, isHidden, description, sortIndex); }
From source file:de.fahrgemeinschaft.util.EditTextImageButton.java
public EditTextImageButton(Context context, AttributeSet attrs) { super(context, attrs); text = (AutoCompletePicker) findViewById(R.id.text); text.setThreshold(1);/*from ww w . j a v a2s . co m*/ text.setId(ID--); text.setHint(getContext().getString(attrs.getAttributeResourceValue(droid, HINT, R.string.app_name))); text.setInputType((attrs.getAttributeIntValue(droid, INPUT_TYPE, InputType.TYPE_CLASS_TEXT))); text.addTextChangedListener(this); Util.fixStreifenhoernchen(text); text.setSelectAllOnFocus(true); icon.setOnClickListener(this); }
From source file:com.anysoftkeyboard.dictionaries.ExternalDictionaryFactory.java
@Override protected DictionaryAddOnAndBuilder createConcreteAddOn(Context askContext, Context context, String prefId, int nameId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) { final String language = attrs.getAttributeValue(null, XML_LANGUAGE_ATTRIBUTE); final String assets = attrs.getAttributeValue(null, XML_ASSETS_ATTRIBUTE); final int dictionaryResourceId = attrs.getAttributeResourceValue(null, XML_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID);/*from www . jav a 2s . com*/ final int autoTextResId = attrs.getAttributeResourceValue(null, XML_AUTO_TEXT_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID); final int initialSuggestionsId = attrs.getAttributeResourceValue(null, XML_INITIAL_SUGGESTIONS_ARRAY_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID); //asserting if (TextUtils.isEmpty(prefId) || (language == null) || (nameId == AddOn.INVALID_RES_ID) || ((assets == null) && (dictionaryResourceId == AddOn.INVALID_RES_ID))) { Logger.e(TAG, "External dictionary does not include all mandatory details! Will not create dictionary."); return null; } else { final DictionaryAddOnAndBuilder creator; if (dictionaryResourceId == AddOn.INVALID_RES_ID) creator = new DictionaryAddOnAndBuilder(askContext, context, prefId, nameId, description, isHidden, sortIndex, language, assets, initialSuggestionsId); else creator = new DictionaryAddOnAndBuilder(askContext, context, prefId, nameId, description, isHidden, sortIndex, language, dictionaryResourceId, autoTextResId, initialSuggestionsId); return creator; } }
From source file:com.example.leapfrog.userbasedictionary.dictionary.ExternalDictionaryFactory.java
@Override protected DictionaryAddOnAndBuilder createConcreteAddOn(Context askContext, Context context, String prefId, int nameId, String description, int sortIndex, AttributeSet attrs) { final String language = attrs.getAttributeValue(null, XML_LANGUAGE_ATTRIBUTE); final String assets = attrs.getAttributeValue(null, XML_ASSETS_ATTRIBUTE); final int dictionaryResourceId = attrs.getAttributeResourceValue(null, XML_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID);/*from ww w . j ava 2 s . c o m*/ final int autoTextResId = attrs.getAttributeResourceValue(null, XML_AUTO_TEXT_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID); final int initialSuggestionsId = attrs.getAttributeResourceValue(null, XML_INITIAL_SUGGESTIONS_ARRAY_RESOURCE_ATTRIBUTE, AddOn.INVALID_RES_ID); //asserting if (TextUtils.isEmpty(prefId) || (language == null) || (nameId == AddOn.INVALID_RES_ID) || ((assets == null) && (dictionaryResourceId == AddOn.INVALID_RES_ID))) { Log.e(TAG, "External dictionary does not include all mandatory details! Will not create dictionary."); return null; } else { final DictionaryAddOnAndBuilder creator; if (dictionaryResourceId == AddOn.INVALID_RES_ID) { creator = new DictionaryAddOnAndBuilder(askContext, context, prefId, nameId, description, sortIndex, language, assets, initialSuggestionsId); } else { creator = new DictionaryAddOnAndBuilder(askContext, context, prefId, nameId, description, sortIndex, language, dictionaryResourceId, autoTextResId, initialSuggestionsId); } return creator; } }