/** Updates a target in the GlowPadView */ private void setTarget( int position, String uri, Drawable draw, String iconType, String iconSource, String pkgName) { TargetInfo item = mTargetStore.get(position); StateListDrawable state = (StateListDrawable) item.icon; LayerDrawable inActiveLayer = (LayerDrawable) state.getStateDrawable(0); LayerDrawable activeLayer = (LayerDrawable) state.getStateDrawable(1); inActiveLayer.setDrawableByLayerId(1, draw); boolean isSystem = iconType != null && iconType.equals(GlowPadView.ICON_RESOURCE); if (!isSystem) { final Drawable activeBack = mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_target_activated); activeLayer.setDrawableByLayerId(0, new InsetDrawable(activeBack, 0, 0, 0, 0)); activeLayer.setDrawableByLayerId(1, draw); } else { InsetDrawable empty = new InsetDrawable(mResources.getDrawable(android.R.color.transparent), 0, 0, 0, 0); activeLayer.setDrawableByLayerId(1, empty); int activeId = mResources.getIdentifier( iconSource.replaceAll("_normal", "_activated"), "drawable", "android"); Drawable back = null; if (activeId != 0) { back = mResources.getDrawable(activeId); activeLayer.setDrawableByLayerId(0, back); } else { final Drawable activeBack = mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_target_activated); activeLayer.setDrawableByLayerId(0, new InsetDrawable(activeBack, 0, 0, 0, 0)); } } item.defaultIcon = mDialogIcon.getDrawable().getConstantState().newDrawable().mutate(); item.uri = uri; item.iconType = iconType; item.iconSource = iconSource; item.pkgName = pkgName; }