diff options
Diffstat (limited to 'src/com')
6 files changed, 53 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/photoeditor/EffectsBar.java b/src/com/android/gallery3d/photoeditor/EffectsBar.java index fad0b90ae..88830bec7 100644 --- a/src/com/android/gallery3d/photoeditor/EffectsBar.java +++ b/src/com/android/gallery3d/photoeditor/EffectsBar.java @@ -71,8 +71,13 @@ public class EffectsBar extends LinearLayout { effectsGallery = inflater.inflate(R.layout.photoeditor_effects_gallery, this, false); ViewGroup scrollView = (ViewGroup) effectsGallery.findViewById(R.id.scroll_view); ViewGroup effects = (ViewGroup) inflater.inflate(effectsId, scrollView, false); - for (int i = 0; i < effects.getChildCount(); i++) { - setupEffect((EffectAction) effects.getChildAt(i)); + for (int i = effects.getChildCount()-1; i >= 0; i--) { + EffectAction effect = (EffectAction) effects.getChildAt(i); + if( !effect.isPresent() ){ + effects.removeViewAt(i); + continue; + } + setupEffect(effect); } scrollView.addView(effects); scrollView.scrollTo(0, 0); diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java index 92bcee4a9..ce0ee6352 100644 --- a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java @@ -144,6 +144,15 @@ public abstract class EffectAction extends LinearLayout { } /** + * Checks if the action effect is present in the system. + * + * @return boolean true if an action effect is present in the system and can be loaded + */ + public boolean isPresent() { + return true; + } + + /** * Done callback for executing top filter changes. */ private class FilterChangedCallback implements OnDoneCallback { diff --git a/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java b/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java index 6b8f1d1b7..e66fc58d6 100644 --- a/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java @@ -52,4 +52,9 @@ public class FaceTanAction extends EffectAction { filter.setScale(DEFAULT_SCALE); notifyChanged(filter); } + + @Override + public boolean isPresent() { + return FaceTanFilter.isPresent(); + } } diff --git a/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java index 4c1a91892..6787d45d6 100644 --- a/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java @@ -52,4 +52,9 @@ public class FaceliftAction extends EffectAction { filter.setScale(DEFAULT_SCALE); notifyChanged(filter); } + + @Override + public boolean isPresent() { + return FaceliftFilter.isPresent(); + } } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java index c52bb8848..b7a1cf1c7 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java @@ -17,6 +17,7 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; +import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; @@ -27,10 +28,22 @@ public class FaceTanFilter extends AbstractScaleFilter { public static final Creator<FaceTanFilter> CREATOR = creatorOf(FaceTanFilter.class); + private static final String EFFECT_FACE_TANNING = "com.google.android.media.effect.effects.FaceTanningEffect"; + @Override public void process(Photo src, Photo dst) { - Effect effect = getEffect("com.google.android.media.effect.effects.FaceTanningEffect"); + Effect effect = getEffect(EFFECT_FACE_TANNING); effect.setParameter("blend", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } + + /** + * Checks if the effect is present in the system. + * + * @return boolean true if an effect is present in the system and can be loaded + */ + public static boolean isPresent() { + return EffectFactory.isEffectSupported(EFFECT_FACE_TANNING); + } + } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java index c6ad84b80..3e4fad206 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java @@ -17,6 +17,7 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; +import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; @@ -27,10 +28,21 @@ public class FaceliftFilter extends AbstractScaleFilter { public static final Creator<FaceliftFilter> CREATOR = creatorOf(FaceliftFilter.class); + private static final String EFFECT_FACELIFT = "com.google.android.media.effect.effects.FaceliftEffect"; + @Override public void process(Photo src, Photo dst) { - Effect effect = getEffect("com.google.android.media.effect.effects.FaceliftEffect"); + Effect effect = getEffect(EFFECT_FACELIFT); effect.setParameter("blend", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } + + /** + * Checks if the effect is present in the system. + * + * @return boolean true if an effect is present in the system and can be loaded + */ + public static boolean isPresent() { + return EffectFactory.isEffectSupported(EFFECT_FACELIFT); + } } |